<template>
	<view class="container">
		<!-- 可用的个人店铺地址 -->
		<scroll-view scroll-y="true" class="list_scroll">
			<view class="list_box">
				<view class="label box_shadow" @click.stop="selectFirmAddress(index)" v-for="(item, index) in firmAddressList" :key="index">
					<view class="addressInfo">
						<view class="title">
							<view class="name">{{item.exJson.name}}</view>
							<view class="mobbile">{{item.exJson.mobile}}</view>
						</view>
						<view class="addressText">{{item.exJson.province}}{{item.exJson.city}}{{item.exJson.district}}{{item.exJson.address}}{{item.exJson.houseNumber}}</view>
						<view class="editIcon">
							<aicon v-if="firmAddressIndex === index" type="roundcheckfill" :color="_temp_themeColor" size="25"></aicon>
							<aicon v-else type="round" color="#bebebe" size="25"></aicon>
						</view>
					</view>
				</view>
				<view class="emptyGoods" v-if="firmAddressList.length===0">
					<u-empty
						text="暂无地址信息"
						mode="data"
						icon="http://cdn.uviewui.com/uview/empty/data.png"
					>
					</u-empty>
				</view>
			</view>
		</scroll-view>
		<view class="footer1">
			<view class="label">
				<view class="button" :style="{backgroundColor: _temp_themeColor}" @click="addressEnter">确认</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { mapState, mapMutations } from 'vuex'
	export default {
		name:"firm-address-list",
		data() {
			return {
				firmAddressList: [],
				firmAddressIndex: 0
			};
		},
		computed: {
			...mapState('firm_store', ['firmList'])
		},
		methods: {
			...mapMutations('app_store', ['SET_CURRENT_ADDRESS']),
			// 选择店铺地址
			selectFirmAddress (index) {
				this.firmAddressIndex  = index;
			},
			addressEnter () {
				let selectedItem = this.firmAddressList[this.firmAddressIndex].exJson;
				console.log(selectedItem, 'selectedItem')
				this.SET_CURRENT_ADDRESS(selectedItem);
				this.$bus.$emit('selectClose');
			}
		},
		mounted () {
			// let firmAddressList = this.firmList.filter((item) => {
			// 	return item.isAudit == 2;
			// });
			// this.firmAddressList = firmAddressList;
			
			this.firmAddressList = [this.currentFirm];
		},
	}
</script>

<style lang="scss" scoped>
	.container{
		
		.list_scroll{
			height: 55vh;
			
			.list_box{
					
				.label{
					padding: 0 20rpx;
					margin: 20rpx 0;
					background-color: #fff;
					
					.addressInfo{
						padding: 40rpx 0;
						position: relative;
						
						.title{
							display: flex;
							align-items: center;
							padding-bottom: 20rpx;
							
							.name{
								font-weight: bold;
								color: #1c1c1c;
								font-size: 32rpx;
								padding: 0 6rpx;
							}
							
							.mobbile{
								font-size: 28rpx;
								color: #1c1c1c;
								padding-right: 10rpx;
							}
							
							.defaultIcon{
								padding: 0 4rpx;
								border-radius: 4rpx;
								border: 1rpx solid #F9AE3D;
								color: #F9AE3D;
								font-size: 24rpx;
								transform: rotate(360deg);
							}
						}
						.addressText{
							width: 85%;
							color: #666;
							font-size: 28rpx;
							white-space: normal;
							overflow: hidden;
							text-overflow: ellipsis;
						}
					}
					
					.manageBox{
						display: flex;
						justify-content: space-between;
						padding: 20rpx 0;
						align-items: center;
						border-top: 1rpx solid #b6b6b6;
						
						.left{
							display: flex;
							align-items: center;
							font-size: 26rpx;
							color: #666;
							
							.changeDefault{
								display: flex;
								align-items: center;
							}
							.selectDefText{
								display: flex;
								align-items: center;
								padding-left: 6rpx;
							}
						}
						.right{
							font-size: 26rpx;
							color: #666;
						}
						
					}
					.editIcon{
						position: absolute;
						right: 20rpx;
						top: 50%;
						transform: translateY(-50%);
					}
				}
			}
		}
		
		.footer1{
			width: 100%;
			
			.label{
				display: flex;
				align-items: center;
				justify-content: space-between;
				height: 120rpx;
				width: 100%;
				
				.button{
					width: 80%;
					margin: 0 auto;
					height: 80rpx;
					border-radius: 100rpx;
					color: #fff;
					font-size: 32rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					background-color: #71beea;
				}
			}
		}
	}
</style>